<?php

/** libraries
 * http://docs.joomla.org/JToolBarHelper
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

class bgViewbg extends JView
{
	// Overwriting JView display method
	function display($tpl = null) 
	{
	   
       $model = $this->getModel();
       $aut = new bgAuthorize(); 
    
        switch(JRequest::getVar('task')){
            case 'error':
                $this->row = (object)JRequest::getVar('jform');
                $this->questionare = & $model->getQuestionare();
                JToolBarHelper::title( 'ページ情報作成', 'info.png' );
                JToolBarHelper::save('save','登録');
                JToolBarHelper::cancel('cancel', 'キャンセル');
                $this->setLayout('edit');
                
                break;
            /* edit question page */
            case 'edit':
                $this->questionare = & $model->getQuestionare();
                $cid = JRequest::getVar('cid');
                $this->row = $model->load($cid[0]);
              
                JToolBarHelper::title( 'ページ編集', 'info.png' );
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
                $this->setLayout('edit');
                break;
                
            /* add question page */ 
            case 'add':
                $this->questionare = & $model->getQuestionare();
             
                JToolBarHelper::title( 'ページ作成', 'info.png' );
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
                $this->setLayout('edit');
                break;
            
            /* get default value */    
            default :
                $this->list['filter_search'] = &JRequest::getVar('filter_search');
                $this->list['status'] = &JRequest::getVar('status');
                $this->rows =& $model->getAll($this->list); 
                $this->pagination =& $this->get('Pagination');
                
                 
            	JToolBarHelper::title( 'ページ管理', 'info.png');
                if($aut->checkAdd()){
                    JToolBarHelper::addNew('add','作成');
                }
                if($aut->checkEdit()){
                    JToolBarHelper::editList('edit', '編集');
                }
                if($aut->checkDelete()){
                    JToolBarHelper::deleteList('', 'remove','削除');
                }
		}
        
		parent::display();
	}
}




